/**
 * Copyright (c) 2013 onionframework.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.onionframework.core.components;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamOmitField;


/**
 * 组件中可选的部分
 * @author allan
 *
 */
public class OptionalPart {

	@XStreamAsAttribute private String id;
	@XStreamAsAttribute private String name;
	private String description;
	@XStreamAsAttribute private String location;
	@XStreamOmitField private boolean loaded = false;
	@XStreamOmitField private String[] resources;
	
	public OptionalPart(String id, String name, String description) {
		super();
		this.id = id;
		this.name = name;
		this.description = description;
	}
	
	public void loaded(String[] resources){
		this.resources = resources;
		this.loaded = true;
	}
	
	public void notLoaded(String[] resources){
		this.resources = resources;
		this.loaded = false;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @return the location
	 */
	public String getLocation() {
		return location;
	}

	/**
	 * @return the loaded
	 */
	public boolean isLoaded() {
		return loaded;
	}

	/**
	 * @return the resources
	 */
	public String[] getResources() {
		return resources;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	
	public String toString(){
		return new ToStringBuilder(this,ToStringStyle.SHORT_PREFIX_STYLE)
			.append("id", this.id)
			.append("name", this.name).toString();
	}
}
